<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.List,edu.rit.cs.core.pojos.Symbol;" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<style type="text/css">
label { display: block; }
div { width: 500px; margin: 10px auto; }
td, th { border-left: 1px solid black; text-align: center; padding: 4px; }
table, th { border-bottom: 1px solid black; } 
table { border-right: 1px solid black; }
table, tfoot td { border-top: 1px solid black; }
tfoot td, td.price { text-align: right; }
</style>
<title>Stocks</title>
</head>
<body>
  <div>
    <form action="Symbols" method="post">
      <fieldset>
        <legend>Stock Information</legend>
        <p>
          <label for="symbol">Symbol:</label>
          <input type="text" name="symbol" id="symbol" maxlength="6"/>
        </p>
        <p>
          <label for="fullname">Fullname:</label>
          <input type="text" name="fullname" id="fullname" maxlength="255" />
        </p>
        <p>
          <label for="price">Price:</label>
          <input type="text" name="price" id="price" />
        </p>
        <p>
          <input type="submit" value="Create" />
        </p>
      </fieldset>
    </form>
  </div>
<% List<Symbol> list = (List<Symbol>) request.getSession().getAttribute("symbols"); %>
  <div>
    <strong>Stocks list:</strong>
    <table cellpadding="0" cellspacing="0">
      <thead>
        <tr>
          <th>Symbol</th>
          <th>Fullname</th>
          <th>Price</th>
        </tr>
      </thead>
      <tfoot>
        <tr>
          <td colspan="2"><strong>Total symbols:</strong></td>
          <td><%= list.size() %></td>
        </tr>
      </tfoot>
      <tbody> 
      <% for (Symbol s : list) { %>
        <tr>
          <td><%= s.getId() %></td>
          <td><%= s.getFullname() %></td>
          <td class="price"><%= String.format("%.3f", s.getPrice()) %></td>
        </tr>
      <% } %>
      </tbody>
    </table>
  </div>
</body>
</html>